package plus.chendd.client;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * Redis客户端
 */
@SuppressWarnings("all")
public class RedisClient {
  
  @Autowired
  private RedisTemplate redisTemplate;
  
  /**
   * redis string set方法 跟原生redis api保持一致
   *
   * @param key   键
   * @param value 值
   */
  public void set(String key, Object value) {
    redisTemplate.opsForValue().set(key, value);
  }
  
  /**
   * redis string getset
   *
   * @param key   键
   * @param value 值
   * @return
   */
  public Object getset(String key, Object value) {
    return redisTemplate.opsForValue().getAndSet(key, value);
  }
  
  /**
   * redis string get
   *
   * @param key 键
   * @return
   */
  public Object get(String key) {
    return redisTemplate.opsForValue().get(key);
  }
}
